package com.weijianhuawen.wjblog.common.validator;


import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @version: java version 8
 * @Author: weijianhuawen
 * @description: 邮箱名校验器
 * @date: 2025-03-26 0:24
 */
public class MailNameValidator implements ConstraintValidator<MailName, String> {

    @Override
    public void initialize(MailName constraintAnnotation) {

    }

    @Override
    public boolean isValid(String mail, ConstraintValidatorContext constraintValidatorContext) {
        // 邮箱校验逻辑
        return mail.matches("^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$");
    }
}
